package com.marry.daodao.authserver.domain;

import lombok.Getter;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.time.LocalDateTime;
import java.util.Collection;

/**
 * @author mal
 * @date 2022-11-15 11:35
 */
@Getter
@Setter
public class User implements UserDetails {

    private String username;
    private String password;
    private LocalDateTime passwordTime;
    private String name;
    private Long userId;
    private String userType;
    private String userPost;
    private boolean locked;
    private boolean canceled;
    private Collection<GrantedAuthority> authorities;
    private Long officeId;
    private String distCode;
    private String userRank;
    private boolean active;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return !locked;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return active;
    }
}
